﻿package frEngine.animateControler
{
    import baseEngine.core.*;
    import baseEngine.modifiers.*;
    import flash.events.*;
    import frEngine.*;
    import frEngine.core.*;
    import frEngine.event.*;

    public class MeshAnimateBase extends Modifier
    {
        public var targetMesh:Mesh3D;
        public var targetSurface:FrSurface3D;

        public function MeshAnimateBase()
        {
            return;
        }// end function

        override public function set targetObject3d(param1:Pivot3D) : void
        {
            var _loc_2:uint = 0;
            this.targetMesh = Mesh3D(param1);
            super.targetObject3d = param1;
            if (this.targetMesh)
            {
                _loc_2 = this.targetMesh.getSurfacesLen();
                if (_loc_2 == 0)
                {
                    FrEventDispatcher.instance.proxyAddEventListener(this.targetMesh, Engine3dEventName.SetMeshSurface, this.setSurfaceHander);
                }
                else
                {
                    this.setSurfaceHander(null);
                }
            }
            return;
        }// end function

        protected function setSurfaceHander(event:Event) : void
        {
            this.targetSurface = this.targetMesh.getSurface(0);
            return;
        }// end function

        override public function dispose(param1:Boolean = true) : void
        {
            if (this.targetMesh)
            {
                FrEventDispatcher.instance.proxyRemoveEventListener(this.targetMesh, Engine3dEventName.SetMeshSurface, this.setSurfaceHander);
            }
            super.dispose();
            this.targetSurface = null;
            this.targetMesh = null;
            return;
        }// end function

    }
}
